package com.gitee.ykr.lightweight.rpc.common.entity;

import io.netty.channel.ChannelFuture;
import lombok.Data;

import java.util.Objects;

/**
 * 封装了异步连接的实例
 * @author YKR
 * @Describe
 * @date 2021/8/23
 */
@Data
public class ConnectionEntity {

    //集群的实例
    private AppEntity appEntity;
    //异步的核心，用来在之后某个时间点确认操作结果
    private ChannelFuture channelFuture;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ConnectionEntity)) return false;
        ConnectionEntity entity = (ConnectionEntity) o;
        return Objects.equals( getAppEntity(), entity.getAppEntity() );
    }

    @Override
    public int hashCode() {

        return Objects.hash( getAppEntity() );
    }

    @Override
    public String toString() {
        return "ConnectionEntity{" +
                "appEntity=" + appEntity +
                ", channelFuture=" + channelFuture +
                '}';
    }
}
